﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Util
{
   public  class JSON
    {


        /// <summary>
        /// 泛型转json
        /// </summary>
       public static string Obj2Json<T>(T data)
       {
           try
           {
               return JsonConvert.SerializeObject(data);

           }
           catch
           {
               return "";
           }
       }

       /// <summary>
       /// 判断是否为数字
       /// </summary>
       public static bool IsNumber<T>(T data) {
           try
           {
               Convert.ToInt32(data);
               return true;
           }
           catch
           {
               return false;

           }
       }
    }
}
